package br.com.insula.twithis.ui.component;

import net.rim.device.api.ui.DrawTextParam;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.EditField;

public class BorderEditField extends EditField {

	public BorderEditField() {
		super(EditField.NO_NEWLINE);
	}

	public BorderEditField(long style) {
		super(style);
	}

	public BorderEditField(String label, String initialValue, int maxNumChars, long style) {
		super(label, initialValue, maxNumChars, style);
	}

	public BorderEditField(String label, String initialValue) {
		super(label, initialValue);
	}

	protected void drawFocus(Graphics g, boolean on) {
		int color = g.getColor();
		Font font = this.getFont();
		
		if (on) {
			g.setColor(0x00CCCCCC);
			g.fillRoundRect(0, 0, font.getAdvance(this.getText()), font.getHeight(), 12, 12);
		} else {
			g.setColor(0x00FFFFFF);
			g.fillRect(0, 0, font.getAdvance(this.getText()), font.getHeight());
		}
		
		g.setColor(color);
		super.drawFocus(g, on);
	}
	
	public int drawText(Graphics g, int offset, int length, int x, int y, DrawTextParam drawTextParam) {
		int color = g.getColor();

		Font font = this.getFont();
		g.setColor(0x00CCCCCC);

		g.fillRoundRect(0, 0, font.getAdvance(this.getText()), font.getHeight(), 12, 12);

		g.setColor(color);
		return super.drawText(g, offset, length, x, y, drawTextParam);
	}

}
